package com.example.a10928.weifriend.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.a10928.weifriend.R;

public class MenuButtomOptionLayout extends RelativeLayout {
    TextView tv_title;
    ImageView iv;

    public MenuButtomOptionLayout(Context context) {
        super(context);
    }

    public MenuButtomOptionLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.layout_menu_buttom_option, this);
        iv = (ImageView) findViewById(R.id.iv);
        tv_title = (TextView) findViewById(R.id.tv);


        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MenuButtomOptionLayout);
        int drawable = typedArray.getResourceId(R.styleable.MenuButtomOptionLayout_MenuButtomOptionLayout_iv, R.drawable.home_page);
        String title = typedArray.getString(R.styleable.MenuButtomOptionLayout_MenuButtomOptionLayout_tv);
        if (title == null) {
            title = "";
        }

        typedArray.recycle();//释放资源

        iv.setBackgroundResource(drawable);
        tv_title.setText(title);
    }


    public ImageView getIv(){
        return iv;
    }
}
